<template>
  <div>
    <h1>对象显示：</h1>
    <p>{{$store.state.info}}</p>

    <!-- <button @click="updateInfo">更新对象</button> -->
    <button @click="updateInfo">更新对象</button>

    <h1>我是首页</h1>
    <p>我是内容，哈哈哈</p>
    <h1>{{$store.state.msg}}</h1>
    <h1>{{$store.state.count}}</h1>

    <button @click="add">+++</button>
    <button @click="del">---</button>

    <router-link to="/home/news">新闻</router-link>
    <router-link to="/home/message">消息</router-link>
    <keep-alive>
      <router-view />
    </keep-alive>
  </div>
</template>

<script>
import { type } from "@/store/mutations.type";

export default {
  name: "Home",

  methods: {
    add() {
      this.$store.commit({
        type: type.INCRETMENT,
        count: 1
      });
    },

    del() {
      this.$store.commit({
        type: type.DECREMENT,
        count: 1
      });
    },
    // updateInfo() {
    //    this.$store.commit({

    //      type: type.UPDATEINFO,
    //      name: 'shiguiwu'
    //    })
    // }
    updateInfo() {
      this.$store.dispatch({
        type: type.AUPDATEINFO,
        name: "shiguiwu1111"
      });
    }
  }
};
</script>

<style>
</style>